//
// Created by TianBo on 2022/6/6.
//

//双指针  滑动窗口  哈希set

#include "iostream"
#include "vector"
#include "unordered_set"

using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        unordered_set<char> uset;
        int right = 0;
        int res = 0;

        for (int left = 0; left < s.size(); ++left) {
            if(left != 0)
                uset.erase(s[left-1]);
            while (right < s.size() && !uset.count(s[right]))
            {
                uset.insert(s[right]);
                right++;
            }
            res = max(res,right-left);
        }
        return res;
    }
};

int main()
{

}